﻿using System.Configuration;

namespace AB.Common
{
    /// <summary>
    /// 配置项
    /// </summary>
    public class ConfigHelper
    {
        /// <summary>
        /// 获取Int类型配置项
        /// </summary>
        /// <param name="key"></param>
        /// <param name="defaultvalue"></param>
        /// <returns></returns>
        public static int IntConfig(string key, int defaultvalue)
        {
            string _int = ConfigurationManager.AppSettings[key];
            return _int.ABToInt(defaultvalue);
        }
        /// <summary>
        /// 获取String类型配置项
        /// </summary>
        /// <param name="key"></param>
        /// <param name="defaultvalue"></param>
        /// <returns></returns>
        public static string StringConfig(string key, string defaultvalue = null)
        {
            string _value = ConfigurationManager.AppSettings[key];
            return _value.ABToString(defaultvalue);
        }
    }
}
